import java.util.Arrays;
import java.util.Scanner;

public class TestDay20 {

    public static void main1(String[] args) {
        //翻转字符串
        Scanner scanner = new Scanner(System.in);
       char[]array = scanner.nextLine().toCharArray();
        int left = 0;
        int right = array.length-1;

        while (left<right){
            char c = array[left];
            array[left] = array[right];
            array[right] = c;
            left++;
            right--;

        }
        for (int i = 0; i < array.length ; i++) {
            System.out.print(array[i]);
        }
    }
    //求最长公共字符串长度
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        getMaxSubstr(str1,str2);

    }
    public static void getMaxSubstr(String s1,String s2){
        //创建两个数组,
        //保证array1的长度是短的
        char[] array1 = s1.toCharArray();
        char[] array2 = s2.toCharArray();
        int len1 = array1.length;
        int len2 = array2.length;
        int max = 0;//记录最大值
        int[][]p = new int[len1+1][len2+1];
        for (int i = 1; i <=array1.length ; i++) {

            for (int j = 1; j <=array2.length ; j++) {
                //如果两个相等
                if(array1[i-1] == array2[j-1]){
                    p[i][j] = p[i-1][j-1]+1;
                }
                if(p[i][j] > max){
                    //记录最大值
                    max = p[i][j];
                }
            }
        }
        System.out.println(max);

    }
}
